package com.fitness.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fitness.model.Address;
import com.fitness.model.Camp;
import com.fitness.model.Classification;
import com.fitness.model.Commodity;
import com.fitness.model.Order;
import com.fitness.model.PrivateTeacher;
import com.fitness.model.Class;
import com.fitness.model.TimeFrame;
import com.fitness.model.WxInformation;
import com.fitness.service.PersonService;

@Controller
public class PersonController {

	@Autowired
	PersonService personService;
	
	/**
	 * 所有的老师
	 */
	@ResponseBody 
	@RequestMapping(value="api/teacher/all",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String allTeacher(Class cl){
		String str = personService.allTeacher(cl);
		return str;
	}
	
	
	/**
	 * 所有的时段
	 */
	@ResponseBody 
	@RequestMapping(value="api/timeframe/all",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String allTimeFrame(TimeFrame timeFrame){
		String str = personService.allTimeFrame(timeFrame);
		return str;
	}
	
	
	
	/**
	 * 所有的课程
	 */
	@ResponseBody 
	@RequestMapping(value="api/class/all",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String allClass(Classification classification){
		String str = personService.allClass(classification);
		return str;
	}
	
	/**
	 * 所有私人教练
	 */
	@ResponseBody 
	@RequestMapping(value="api/private/teacher",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String privateTeacher(PrivateTeacher privateTeacher){
		String str = personService.privateTeacher(privateTeacher);
		return str;
	}
	
	
	/**
	 * 所有camp
	 */
	@ResponseBody 
	@RequestMapping(value="api/camp/all",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String allCamp(Camp camp){
		String str = personService.allCamp(camp);
		return str;
	}
	
	/**
	 * 所有健身房
	 */
	@ResponseBody 
	@RequestMapping(value="api/fitness/all",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String allFitness(Address address){
		String str = personService.allFitness(address);
		return str;
	}
	
	/**
	 * 地区分类
	 */
	@ResponseBody 
	@RequestMapping(value="api/area/classify",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String areaClassify(Address address){
		String str = personService.areaClassify(address);
		return str;
	}
	
	/**
	 * 健身房详情
	 */
	@ResponseBody 
	@RequestMapping(value="api/fitness/datail",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String fitnessDetail(Address address){
		String str = personService.fitnessDetail(address);
		return str;
	}
	
	/**
	 * 修改健身房信息
	 */
	@ResponseBody 
	@RequestMapping(value="api/fitness/update",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String fitnessUpdate(Address address){
		String str = personService.fitnessUpdate(address);
		return str;
	}
	/**
	 * 通过详细id查询详细信息
	 */
	@ResponseBody 
	@RequestMapping(value="api/class/datail",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String classDetail(Class c){
		String str = personService.classDetail(c);
		return str;
	}
	/**
	 * 根据课程标签查询课程
	 */
	@ResponseBody 
	@RequestMapping(value="api/class/lables",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String classLables(Classification c){
		String str = personService.classLables(c);
		return str;
	}
	
	/**
	 * 根据时段查询课程
	 */
	@ResponseBody 
	@RequestMapping(value="api/class/timeframe",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String timeFrame(TimeFrame t){
		String str = personService.timeFrame(t);
		return str;
	}
	
	/**
	 * 根据城市和时间查询课程
	 */
	@ResponseBody 
	@RequestMapping(value="api/class/area/time",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String areaTime(Address a){
		String str = personService.areaTime(a);
		return str;
	}
	
	/**
	 * 约课的订单列表
	 */
	@ResponseBody 
	@RequestMapping(value="api/class/order",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String classOrder(Order order){
		String str = personService.classOrder(order);
		return str;
	}
	
	/**
	 * 约课的未付款订单列表
	 */
	@ResponseBody 
	@RequestMapping(value="api/class/unpaidOrder",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String unpaidOrder(Order order){
		String str = personService.unpaidOrder(order);
		return str;
	}
	
	/**
	 * 订单详情
	 */
	@ResponseBody 
	@RequestMapping(value="api/class/orderDetail",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String orderDetil(Order order){
		String str = personService.orderDetail(order);
		return str;
	}
	
	/**
	 * 待上课
	 */
	@ResponseBody 
	@RequestMapping(value="api/class/waiting",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String classWaiting(Order order){
		String str = personService.classWaiting(order);
		return str;
	}
	
	/**
	 * 已上课
	 */
	@ResponseBody 
	@RequestMapping(value="api/class/end",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String classEnd(Order order){
		String str = personService.classEnd(order);
		return str;
	}
	
	/**
	 * camp支付表
	 */
	@ResponseBody 
	@RequestMapping(value="api/camp/order",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String campOrder(Order order){
		String str = personService.campOrder(order);
		return str;
	}
	
	/**
	 * 钱包充值
	 */
	@ResponseBody 
	@RequestMapping(value="api/wx/wallet",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String wxWallet(Order order,HttpServletRequest request,HttpServletResponse response){
		String str = personService.wxWallet(order,request);
		return str;
	}
	
	/**
	 * 钱包充值支付回调
	 */
	@ResponseBody 
	@RequestMapping(value="api/wxpay/back",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String wxpayBack(HttpServletRequest request,HttpServletResponse response)throws Exception{
		String str = personService.wxpayBack(request);
		return str;
	}
	
	/**
	 * 用户使用钱包支付订单
	 */
	@ResponseBody 
	@RequestMapping(value="api/wallet/pay",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String walletPay(Order order){
		String str = personService.walletPay(order);
		return str;
	}
	
	/**
	 * 游泳馆买票
	 */
	@ResponseBody 
	@RequestMapping(value="api/commodity/list",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String commodityList(Commodity commodity){
		String str = personService.commodityList(commodity);
		return str;
	}
	
	/**
	 * 游泳馆买票详情
	 */
	@ResponseBody 
	@RequestMapping(value="api/commodity/detail",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String commodityDetail(Commodity commodity){
		String str = personService.commodityDetail(commodity);
		return str;
	}
	
	/**
	 * 通过openid判断是否为会员
	 */
	@ResponseBody 
	@RequestMapping(value="api/vip/isorno",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String vipIsorno(WxInformation wxInformation){
		String str = personService.vipIsorno(wxInformation);
		return str;
	}
	
	/**
	 * 查询单词课程订单
	 */
	@ResponseBody 
	@RequestMapping(value="api/commodity/order",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String commodityOrder(Order order){
		String str = personService.commodityOrder(order);
		return str;
	}
	
	/**
	 * 查询所有私教顶单单接口
	 */
	@ResponseBody 
	@RequestMapping(value="api/private/orderlist",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public  String privateOrderList(Order order){
		String str = personService.privateOrderList(order);
		return str;
	}
	
	
}
